home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Tech Arsenal 1
/
Tech Arsenal (Arsenal Computer).ISO
/
tek-04
/
bipl.zip
/
PROCS.ZIP
/
GCD.ICN
< prev
next >
Wrap
Text File
|
1992-09-28
|
759b
|
33 lines
############################################################################
#
# File: gcd.icn
#
# Subject: Procedures to compute greatest common denominator
#
# Author: Ralph E. Griswold
#
# Date: May 11, 1989
#
###########################################################################
#
# This procedure computes the greatest common denominator of two
# integers. If both are zero, it fails.
#
############################################################################
procedure gcd(i,j)
local r
if i = j = 0 then fail
if i = 0 then return j
if j = 0 then return i
i := abs(i)
j := abs(j)
repeat {
r := i % j
if r = 0 then return j
i := j
j := r
}
end